#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netdb.h>

#define SUCCESS					0
#define FAILURE					-1
#define MULTICAST_PORT				2001
#define MAX_MULTICAST_PKT_LEN			500
#define MAX_IPV4_IP_LEN				16
#define MAX_BUF					1025
#define MAX_PKT_SIZE				65000
#define MAX_TCP_BACKLOG				5
#define MAX_FILENAME_LEN			1025
#define MAX_COMMAND_LEN				1025
#define CONTROL_INFO_RECV_LEN			1500
#define CONTROL_INFO_SEND_LEN			150
#define COMPRESSION_SERVER_TCP_PORT		2000
#define MULTICAST_IP				"226.0.0.1"
#define MULTICAST_REQ_MSG			"Who has Decompression"
#define MULTICAST_RES_MSG			"Decompression@"
#define INTERFACE				"{68C53B21-8DA0-4931-A88B-E1B3A35B3275}"
#define MULTICAST_COMPRESSION_REQ_MSG		"Who has Decryption"
#define MULTICAST_COMPRESSION_RES_MSG		"Decryption@"

struct credential {
	char filename[MAX_FILENAME_LEN];
	int size;
}__attribute__((packed));

struct nextHop {
	int clientIP;
	char filename[MAX_FILENAME_LEN];
	int size;
}__attribute__((packed));

int validateinfo(int, char **);
void Multicast(void);
char *getSystemIP(char *pIP, char *pMACif);
char * getIP(const struct sockaddr *pSA, char *pIP);
int encrypt(char *);
void recvfile(int, FILE *, int);
int getCompressionServer(void);
void sendControlInfoAndFile(int, char *, char *, int);
void sendFile(int, char *, int);

